import axios from '@/utils/request'
// 面试技巧列表接口
function apiGetTechnic ({ start, limit, q }) {
  return axios({
    url: '/articles/technic',
    params: {
      start,
      limit,
      q
    },
    needToken: true
  })
}
// 面经分享列表接口
function apiGetShare ({ start, limit, q }) {
  return axios({
    url: '/articles/share',
    params: {
      start,
      limit,
      q
    },
    needToken: true
  })
}

// 热门职位数据
function apiGetChart () {
  return axios({
    url: '/chart-data/hot'
  })
}
// 面经分享热搜接口
function apiGetTopSearch () {
  return axios({
    url: '/articles/shareTopSearch'
  })
}
// 面经分享文章接口
function apiGetShareDetail (id) {
  return axios({
    url: `/articles/share/${id}`
  })
}
// 面经文章评论
function apiGetcomments ({ id, limit, start }) {
  return axios({
    url: `/articles/comments/${id}`,
    params: {
      limit,
      start
    }
  })
}
// 发表评论
function apiAddComment ({ content, article, parent }) {
  return axios({
    url: '/articles/comments',
    data: {
      content,
      article,
      parent
    },
    method: 'post',
    needToken: true
  })
}
// 点赞文章接口
function apiStar (article) {
  return axios({
    url: '/articles/star',
    data: {
      article
    },
    method: 'post',
    needToken: true
  })
}

// 收藏文章接口
function apiCollect (id) {
  return axios({
    url: '/articles/collect',
    data: {
      id
    },
    method: 'post',
    needToken: true
  })
}

export {
  apiGetTechnic,
  apiGetShare,
  apiGetChart,
  apiGetTopSearch,
  apiGetShareDetail,
  apiGetcomments,
  apiAddComment,
  apiStar,
  apiCollect
}
